package com.spring.shops.dao;

import com.spring.shops.model.entity.TzSku;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TzSkuMapper {
    int deleteByPrimaryKey(Long skuId);

    int insert(TzSku record);

    int insertSelective(TzSku record);

    TzSku selectByPrimaryKey(Long skuId);

    int updateByPrimaryKeySelective(TzSku record);

    int updateByPrimaryKey(TzSku record);

    /**
     * 插入数据
     * @param tzSku
     * @return
     */
     @Insert("insert into yami_shops.tz_sku (prod_id, ori_price, price, stocks, " +
             "actual_stocks, update_time," +
             " rec_time, party_code, model_id, pic, sku_name, prod_name," +
             " weight, volume, is_delete) VALUES (#{prodId},#{oriPrice},#{price},#{stocks},#{actualStocks},#{updateTime}," +
             "#{recTime},#{partyCode},#{modelId},#{pic},#{skuName},#{prodName},#{weight},#{volume},#{isDelete})")
    int save(TzSku tzSku);

    /**
     * 根据产品id获取所有的sku
     * @param prodId
     * @return
     */
    @Select("select * from yami_shops.tz_sku where prod_id=#{proId} and is_delete=0")
    List<TzSku> selectByProdId(Long prodId);

    /**
     * 根据proId删除所有的sku信息
     * @param prodId
     * @return
     */
    @Delete("delete from yami_shops.tz_sku where prod_id=#{prodId}")
    int deleteByProdId(Long prodId);
}